/* Copyright 2008 Bas van den Berg
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef PLAYERSETTINGS_H 
#define PLAYERSETTINGS_H

#include <string>
#include <vector>

namespace Chronos {

class StringBuilder;

class PlayerSettings {
public:
    PlayerSettings();
    
    const std::string& getOption(const std::string& setting) const;
    void setOption(StringBuilder& buffer, const std::string& setting, const std::string& option);
    void add(const char* setting, const char* option1, const char* option2);
    void print(StringBuilder& buffer) const;

    void initialize(const std::string& init);
    std::string toString() const;
private:
    class Setting {
    public:
        Setting(const std::string& name_, const std::string& option1, const std::string& option2);
        void setCurrent(const std::string& option);
        void setCurrent(StringBuilder& buffer, const std::string& option);
        std::string printOptions() const;

        std::string name;
        std::string currentOption;
        typedef std::vector<std::string> Options;
        typedef Options::const_iterator OptionsConstIter;
        Options options;
    };
    typedef std::vector<Setting> Settings;
    typedef Settings::const_iterator SettingsConstIter;
    typedef Settings::iterator SettingsIter;
    Settings settings;

    const Setting* find(const std::string& setting) const;
    Setting* find(const std::string& setting);

    PlayerSettings(const PlayerSettings&);
    PlayerSettings& operator= (const PlayerSettings&);
};

}

#endif

